KISSY.use("node",function(S,Node){ 
$(".title").on("mouseenter mouseleave",function(){
	var key = $(this).attr("data-key");
	$(".cuted"+key).toggleClass("hide");
	$(".cutedtip"+key).toggleClass("hide");
});
function loadmore(select){
	$(select).on("click",function(){
		var msgkey = $(this).attr("data-key");
		KISSY.io({
			url: "/?a=loadmore&m=home&c=admin",
			data: {"msgkey":msgkey},
			success: function(data, textStatus) {
				$('.msgshow').remove();
				var keys=[];
				keys.push(data.a);
				keys.push(data.b);
				keys.push(data.c);
				keys.push(data.d);
				keys.push(data.e);
				keys.push(data.f);
				keys.push(data.g);
				keys.push(data.h);
				keys.push(data.i);
				keys.push(data.j);
				keys.forEach(function(k){
					var msg = "由"+(k.fromshop?k.fromshop:"管理员")+"发给"+k.toshop+"："+k.message;
					var html = "<div><span class=\"x-icon x-icon-small x-icon-success\"><i class=\"icon icon-white icon-share-alt\"></i></span>"+msg+"</div>";
					$(".msgclone .msginfo").empty();
					$(html).appendTo($(".msgclone .msginfo"));
					var t = $(".msgclone").clone(true,true,true);
						t.removeClass("msgclone hidden");
						t.addClass("msgshow");
						t.attr("data-key","assdfasd");
						t.insertAfter($('.tr'+msgkey));
				});
			},
			complete: function(data){
			},
			error: function(){
				alert('error');
			},
			dataType:"jsonp"
		});
	});
}
	$(".bui-nav-tab-item").on("click",function(){
		$(".bui-nav-tab-item").removeClass("tab-nav-actived");
		$(this).addClass("tab-nav-actived");
		var ac =$(this).attr('data-name');
		loadmsgpage(1,ac);
	});
	function loadmsgpage(curpg,ac){
		KISSY.io({
			//指定 callback 的参数,请求 url 会生成 "url?callback={$jsonpCallback}"
			//jsonpCallback: "jsonp100",
			//指定 callback 的别名,请求url会生成 "url?{$jsonp}=jsonp123456"， 默认就是callback
			//jsonp: "callback" ,
			//url 地址
			url: "/?a=ajaxmsglist&m=home&c=admin",
			data: {"ac":ac,"p":curpg},
			success: function(data, textStatus) {
			$(".tbodya").empty();
				var keys=[];
				data.a?keys.push(data.a):'';
				data.b?keys.push(data.b):'';
				data.c?keys.push(data.c):'';
				data.d?keys.push(data.d):'';
				data.e?keys.push(data.e):'';
				data.f?keys.push(data.f):'';
				data.g?keys.push(data.g):'';
				data.h?keys.push(data.h):'';
				data.i?keys.push(data.i):'';
				data.j?keys.push(data.j):'';
				data.k?keys.push(data.k):'';
				data.l?keys.push(data.l):'';
				data.m?keys.push(data.m):'';
				data.n?keys.push(data.n):'';
				data.o?keys.push(data.o):'';
				data.p?keys.push(data.p):'';
				data.q?keys.push(data.q):'';
				data.r?keys.push(data.r):'';
				data.s?keys.push(data.s):'';
				data.t?keys.push(data.t):'';
				keys.forEach(function(k){
					$(".clone .c2").empty();
					$(".clone .c3").empty();
					$(".clone .c4").empty();
					$(".clone .c5").empty();
					$(".clone .c6").empty();
					$(".clone .c7").empty();
					var html='';
					html = '<span class="label label-warning">'+k.fromshop+'</span>';
					$(html).appendTo($(".clone .c2"));
						html = '';
						html += ('<div class="cuted'+k.id+'">'+k.toshopcut+'</div>');
						html += ('	<div class="tips tips-small tips-info tips-no-icon pull-right hide cutedtip'+k.id+'" style="position:absolute">');
						html += ('	  <div class="tips-content"><a href="http://shop'+k.sid+'.taobao.com" target="_blank">'+k.toshop+'</a>');
						html += ('		<i class="icon icon-white icon-envelope mailto pit" data-title="'+k.toshop+'" data-xnick="'+k.sid+'"></i>');
						html += ('	  </div>');
						html += ('</div>');
					$(html).appendTo($(".clone .c3"));
						html = '<span>'+k.message+'</span>';
						if(k.type==2){
						html += '<span class="x-icon x-icon-small x-icon-success "><i class="icon icon-white icon-ok" title="已审核的店铺"></i></span>';
						}else if(k.type==3){
						html += '<span class="x-icon x-icon-small x-icon-error"><i class="icon icon-white  icon-question-sign" title="已驳回店铺"></i></span>';
						}else if(k.type==1){
						html += '<span class="x-icon x-icon-small x-icon-warning"><i class="icon icon-white icon-warning" title="待审核的店铺"></i></span>';
						}else if(k.type==4){
						html += '<span class="x-icon x-icon-small x-icon-warning"><i class="icon icon-white  icon-refresh" title="待审核的店铺"></i></span>';
						}else if(k.type==5){
						html += '<span class="x-icon x-icon-small label-inverse x-icon'+k.sid+'"><i class="icon icon-white icon-ban-circle icon'+k.sid+'"></i></span>';
						}
					$(html).appendTo($(".clone .c4"));
						html = '<span class="x-icon x-icon-info "><i class="icon icon-white icon-comment mailto pit" data-title="'+k.toshop+'" data-xnick="'+k.sid+'" data-msgid="'+k.id+'"></i></span>'
					$(html).appendTo($(".clone .c5"));
						html = '<span class="count'+k.id+'">'+k.response+'</span>';
						html += ('		<div style="padding-top:4px;float:right;">');
						if(k.response==0){
							html += ('			<span class="x-icon x-icon-mini x-icon-disable xicon'+k.id+'">');
							html += ('				<i class="icon icon-minus-mini icon'+k.id+'"></i>');
							html += ('			</span>');
						}else{
							html += ('			<span class="x-icon x-icon-mini x-icon-info">');
							html += ('				<i class="icon icon-white icon-plus-mini loadmore pit" data-key="'+k.id+'"></i>');
							html += ('			</span>');
						}
						html += ('		</div>');
					$(html).appendTo($(".clone .c6"));
						html='<span>'+k.sendtime+'<span>';
					$(html).appendTo($(".clone .c7"));
					var t = $(".clone").clone(true,true,true);
					t.removeClass("clone hidden");
					t.addClass("tr"+k.id);
					t.children('.c3').on("mouseenter mouseleave",function(){
						$(".cuted"+k.id).toggleClass("hide");
						$(".cutedtip"+k.id).toggleClass("hide");
					});
					t.attr("data-sid",k.sid);
					t.appendTo($('.tbodya'));
				});
				loadmore(".loadmore");
				$(".mailto").on("click",function(){
						sendmsg_box($(this).attr("data-title"),$(this).attr("data-xnick"),$(this).attr("data-msgid")?$(this).attr("data-msgid"):0);
				});
			},
			//function 请求完成的回调，在 success 调用之后触发,参数同 success
			complete: function(data){
				setPage($('.pagination'),data.totalpg,curpg);
				// $('.pagination').attr("data-totalpg",data.totalpg);
				// $('.pagination').attr("data-curpg",data.curpage)
				// $('.pagination').empty();
				// setPage($('.pagination'),data.totalpg,data.curpage);
			},
			// 请求错误时的回调
			error: function(){
				alert('error');
			},
			//发送请求类型是jsonp
			dataType:"jsonp"
		});
	}
	loadmore(".loadmore");
	$(".mailto").on("click",function(){
		var shoptitle = $(this).attr("data-title");
		var mixednick = $(this).attr("data-xnick");
		var msgid = $(this).attr("data-msgid")?$(this).attr("data-msgid"):0;
		sendmsg_box(shoptitle,mixednick,msgid);
	});
$('.pagination').empty();
setPage($('.pagination'),$('.pagination').attr("data-totalpg"),$('.pagination').attr("data-curpg"));
});